;; here are somt functions useful when writing perl scripts
;; author Ting Wang
;; version: 0.1
;;   provide functions: 
;;   perl-insert-head 
;;   perl-insert-discription
;;   perl-insert-openfile 
;;   perl-insert-debugmessage 
;;   perl-dumper
;;   perl-contructor
;;   perl-new-subroutine
(defun perl-insert-head ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (insert "#! /usr/bin/perl -w\nBEGIN\n{\nunshift (\@INC, \"/home/tiw/perl/include\");\nunshift (@INC, \"/home/tiw/sh/\");\nunshift (\@INC,  \"/home/tiw/perl/lib/perl5/5.8.0/\");\nunshift (\@INC,  \"/home/tiw/perl/lib/perl5/site_perl/5.8.0/\");\nunshift (\@INC, \"/home/tiw/perl/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/\");\n}\nuse strict;\nuse tiwUtil;\n")))
(defun perl-insert-discription (dis)
  (interactive "sYour discription: ")
  (insert "#==================================================================\n")
  (insert "# ")
  (insert dis)
  (insert "\n#==================================================================\n"))
(defun perl-insert-openfile (fileName fileHandel)
  (interactive "sFile name:
sFile handel name:")
  (insert (concat "open " fileHandel ", \"" fileName "\" or die \"can not open " fileName "$!\\n \"")))

(defun perl-insert-debugmessage (msg)
  (interactive "sThe debug message is: ")
  (insert "warn \"")
  (insert msg)
  (insert "\" if $DEBUG;"))
(defun perl-dumper (var)
  (interactive "sThe variable to dumper is: ")
  (insert "warn Dumper(")
  (insert var)
  (insert ") if $DEBUG;"))
(defun perl-new-subroutine (subName)
  (interactive "sThe name of subroutine is: ")
  (insert "sub ")
  (insert subName)
  (insert "\n{\n\n}")
  (previous-line 1))
(defun perl-contructor ()
  (interactive)
  (insert "
sub new {
  my $proto = shift;
  my $class = ref($proto) || $proto;
  my $self = {};
  bless($self, $class);
  return $self;
}

#----------------------------------------------------------------------
1;
")
  (previous-line 3))
